using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InvestmentIntelligence.DbModel.Models.Mapping
{
    public class TradeConsistencyCheckMap : EntityTypeConfiguration<TradeConsistencyCheck>
    {
        public TradeConsistencyCheckMap()
        {
            // Primary Key
            this.HasKey(t => new { t.FundBookEntityId, t.SecurityId, t.Date });

            // Properties
            this.Property(t => t.FundBookEntityId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.SecurityId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("TradeConsistencyCheck", "TradingData");
            this.Property(t => t.FundBookEntityId).HasColumnName("FundBookEntityId");
            this.Property(t => t.SecurityId).HasColumnName("SecurityId");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.TodayPosition).HasColumnName("TodayPosition");
            this.Property(t => t.YesterdayPosition).HasColumnName("YesterdayPosition");
            this.Property(t => t.TradeQuantity).HasColumnName("TradeQuantity");

            // Relationships
            this.HasRequired(t => t.FundBookEntity);


            this.HasRequired(t => t.Security);

        }
    }
}
